<?php defined('RUN_KATANA') or die('Restricted access'); ?>
<?php 
$buttons_l[0]['image'] = "csv_16.png";
$buttons_l[0]['onclick'] = "csvExport();";
$buttons_l[0]['title'] = ucfirst($txt->getWord('export'));
echo $commander->getListCommandsPanel('shipping_methods-period-reload', '', $buttons_l);
?>
<div class="menu_list">
	<table style="clear:both;" id="orders_<?php echo $report; ?>" class="item_list" cellspacing="0" cellpadding="0" border="0">
        <thead class="fields">
            <tr>
				<th class="first center"><?php echo ucfirst($txt->getWord('delivery_date')); ?></th>
				<th><?php echo ucfirst($txt->getWord('order_id')); ?></th>
				<th><?php echo ucfirst($txt->getWord('shipping').' '.$txt->getWord('zone')); ?></th>
				<th><?php echo ucfirst($txt->getWord('shipping').' '.$txt->getWord('zone').' '.$txt->getWord('title')); ?></th>
				<th><?php echo ucfirst($txt->getWord('identity')); ?></th>
				<th><?php echo ucfirst($txt->getWord('std_price').' ('.$txt->getWord('inc').'. '.$txt->getWord('tax').')'); ?></th>
				<th class="header last"><?php echo ucfirst($txt->getWord('count')); ?></th>
            </tr>
        </thead>
        <tbody><?php echo $commander->getComponentListLoading(); ?></tbody>
    </table>
</div>
<?php 
$dateStart = date('Y-m-').'01';
$dateEnd = date('Y-m-t');
if($_REQUEST['date_start'] != '')
{ $dateStart = $_REQUEST['date_start']; }
if($_REQUEST['date_end'] != '')
{ $dateEnd = $_REQUEST['date_end']; }
?>
<script type="text/javascript">
jQuery(document).ready(function() 
{
	setPeriod();
	loadTableData<?php echo $report; ?>();
	
});
function loadTableData<?php echo $report; ?>()
{
	jQuery.ajax(
	{
		url: "ajax.php<?php echo $commander->getFormAction('ajax'); ?>&date_start=<?php echo $dateStart; ?>&date_end=<?php echo $dateEnd; ?>",
		cache: false,
	  	success: function(html)
	  	{ 
			jQuery('table#orders_<?php echo $report; ?> tr.loading').remove();
			jQuery("table#orders_<?php echo $report; ?> tbody").append(html); 
			jQuery('table#orders_<?php echo $report; ?>.item_list tr.loading').remove();
		}
	});
}

function csvExport()
{
	jQuery.ajax(
	{
		url: "csv.php<?php echo $commander->getFormAction('ajax'); ?>&date_start=<?php echo $dateStart; ?>&date_end=<?php echo $dateEnd; ?>&output_format=csv&view=download",
		cache: false,
	  	success: function(html)
	  	{ 
			jQuery('div#csv').empty();
			jQuery("div#csv").append(html);
			jQuery('#export_dialog').dialog('open');
			jQuery('#export_dialog').dialog({
				bgiframe: true,
				resizable: true,
				height:160,
				modal: true,
				overlay: 
				{
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: 
				{
					'<?php echo ucfirst($txt->getWord('close')); ?>': function() 
					{ jQuery(this).dialog('close'); }
				}
			});
		}
	});
	
	
}
</script>
<div id="export_dialog" title="<?php echo ucfirst($txt->getWord('download').' '.$txt->getWord('report')); ?>?" style="display:none; text-align:left;">
	<div id="csv"></div>
</div><div class="clear"></div>